import rxAjax from '@/assets/js/ajax.js';

//FORM_ONLYOFFICE api接口
export const FormOnlyOfficeApi = {};

FormOnlyOfficeApi.baseUrl= '/api-form/form/onlyoffice/formOnlyOffice';
FormOnlyOfficeApi.exportUrl= FormOnlyOfficeApi.baseUrl + '/listExport';

//查询列表
FormOnlyOfficeApi.query=function (parameter) {
  var url= FormOnlyOfficeApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
FormOnlyOfficeApi.get =function(pkId) {
  var url= FormOnlyOfficeApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
FormOnlyOfficeApi.save =function(parameter) {
  var url= FormOnlyOfficeApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
FormOnlyOfficeApi.del =function(parameter) {
  var url= FormOnlyOfficeApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

FormOnlyOfficeApi.create =function(form) {
    var url= "/api-form/form/share/onlyoffice/create";
    return rxAjax.postForm(url,form);
}

FormOnlyOfficeApi.getConfig =function(docId) {
    var url= "/api-form/form/share/onlyoffice/getConfig?docId=" + docId;
    return rxAjax.get(url);
}

/**
 * 重命名文件
 * @param json {
 *     newname:"",
 *     key:""
 * }
 * @returns {*}
 */
FormOnlyOfficeApi.rename =function(json) {
    var url= "/api-form/form/share/onlyoffice/rename";
    return rxAjax.postJson(url,json);
}

/**
 * 文件另存为
 * @param json {title:"",url:"",fileType:""}
 * @returns {*}
 */
FormOnlyOfficeApi.saveas =function(json) {
    var url= "/api-form/form/share/onlyoffice/saveas";
    return rxAjax.postJson(url,json);
}


FormOnlyOfficeApi.delByDocId =function(docId) {
    var url= '/api-form/form/share/onlyoffice/delByDocId';
    let params="docId=" + docId;
    return rxAjax.postForm(url,params);
}


FormOnlyOfficeApi.getHistoryByDocId =function(docId) {
    var url= '/api-form/form/share/onlyoffice/getHistoryByDocId';
    let params="docId=" + docId;
    return rxAjax.postForm(url,params);
}


FormOnlyOfficeApi.getVersion =function(docId,version) {
    var url= '/api-form/form/share/onlyoffice/getVersion';
    let params="docId=" + docId +"&version=" + version;
    return rxAjax.postForm(url,params);
}


FormOnlyOfficeApi.changeVersion =function(docId,version) {
    var url= '/api-form/form/share/onlyoffice/changeVersion';
    let params="docId=" + docId +"&version=" + version;
    return rxAjax.postForm(url,params);
}







export  default FormOnlyOfficeApi;

